<?php

class GalactusView {

	protected $control = NULL;
	public $helper = NULL;

	function __construct($control) {
		$this->control = $control;
		$this->helper = new GalactusViewHelper( );
	}

	public function retrieveCSS( ) {
		header("Content-type: text/css");
		echo '
			body > .navbar .brand {
				color: #000;
				text-shadow: 0 1px 0 rgba(255,255,255,.1), 0 0 30px rgba(255,255,255,.125);
				-webkit-transition: all .2s linear;
				-moz-transition: all .2s linear;
				transition: all .2s linear;
			}

			body > .navbar .brand:hover {
				text-decoration: none;
				text-shadow: 0 1px 0 rgba(255,255,255,.1), 0 0 30px rgba(255,255,255,.4);
			}

			a {
				cursor: pointer;
			}

			.shadowinner {
				-moz-box-shadow: inset 0px 0px 10px #ccc;
				-webkit-box-shadow: inset 0px 0px 10px #ccc;
				box-shadow: inset 0px 0px 10px #ccc;
			}

			.shadowoutter {
				-moz-box-shadow: 0px 0px 10px #ccc;
				-webkit-box-shadow: 0px 0px 10px #ccc;
				box-shadow: 0px 0px 10px #ccc;
			}

			.text-justify {
				text-align: justify;
			}

			#contentarea {
				margin-left: 5%;
				padding-top: 60px;
				width: 90%;
			}

			#logo-galactus {
				font-family: "Coda Caption", sans-serif;
			}

			#logo-cnpq {
				margin-left: 35%;
				margin-right: 3%;
				width: 5.5%;
			}

			#logo-ifrn {
				margin-right: 3%;
				width: 5.5%;
			}

			#logo-ufrn {
				margin-right: 3%;
				width: 6.6%;
			}

			#logo-vitae {
				width: 1.6%;
			}
		';
		echo GalactusViewControl::retrieveCSS( );
		echo GalactusViewGallery::retrieveCSS( );
		echo GalactusViewPost::retrieveCSS( );
		echo GalactusViewSchedule::retrieveCSS( );
		echo GalactusViewTeam::retrieveCSS( );
		echo GalactusViewTelescope::retrieveCSS( );
		echo GalactusViewUser::retrieveCSS( );
	}

	public function retrieveJS( ) {
		header("Content-type: text/javascript");
		echo '
			var HEIGHT = 0.9*$(window).height( );
			function galactus_view_show(cmd) {
				var url = "'.URL.'";
				$(".brand").click(function( ) {
					cmd = $(this).attr("galactus-command");
					$("#contentarea").html("");
					$("#contentarea").load(url + cmd);
					$(".navbar li").removeClass("active");
				});
				$(".nav li a").click(function( ) {
					cmd = $(this).attr("galactus-command");
					$("#contentarea").html("");
					$("#contentarea").load(url + cmd);
					$(".navbar li").removeClass("active");
					$(this).parent( ).addClass("active");
				});
				$("#contentarea").load(url + cmd);
				$(".navbar li").removeClass("active");
			}
		';
		echo GalactusViewAccount::retrieveJS( );		
		echo GalactusViewCalendar::retrieveJS( );
		echo GalactusViewControl::retrieveJS( );
		echo GalactusViewPresentation::retrieveJS( );
		echo GalactusViewPost::retrieveJS( );
		echo GalactusViewSchedule::retrieveJS( );
		echo GalactusViewTelescope::retrieveJS( );
		echo GalactusViewUser::retrieveJS( );
	}

	public function show($page = NULL) {
		if(empty($page)) {
			$page = ($this->control->profile_id == NULL)? "PRESENTATION/SHOW/INDEX" : "USER/SHOW/INDEX";
		}
		$content = '
			<div class="navbar navbar-inverse navbar-fixed-top">
				<div class="navbar-inner">
					<div class="container-fluid">
						<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
							<span class="icon-bar"></span>
							<span class="icon-bar"></span>
							<span class="icon-bar"></span>
						</a>
						<a class="brand" id="logo-galactus" galactus-command="USER/SHOW/INDEX">GALACTUS</a>
						<div class="nav-collapse collapse">
							<ul class="nav">
								<li class="active"><a galactus-command="PRESENTATION/SHOW/INDEX">Apresentação</a></li>
								<li><a galactus-command="TELESCOPE/SHOW/INDEX">Telescópios</a></li>
								<li><a galactus-command="GALLERY/SHOW/INDEX">Galeria</a></li>
								<li class="belongs-adm hide"><a galactus-command="POST/SHOW/INDEX">Recados</a></li>
								<li class="belongs-adm hide"><a galactus-command="ACCOUNT/SHOW/INDEX">Contas</a></li>
								<li><a galactus-command="TEAM/SHOW/INDEX">Equipe</a></li>
							</ul>
						</div>
					</div>
				</div>
			</div>
			<div id="contentarea"></div>
			<hr />
			<footer>
				<a href="http://www.cnpq.br"><img src="'.URL.'images/cnpq.png" class="pull-left" id="logo-cnpq" /></a>
				<a href="http://www.ifrn.edu.br"><img src="'.URL.'images/ifrn.png" class="pull-left" id="logo-ifrn" /></a>
				<a href="http://www.ufrn.br"><img src="'.URL.'images/ufrn.png" class="pull-left" id="logo-ufrn" /></a>
				<a href="http://www.vitae.org.br"><img src="'.URL.'images/vitae.png" class="pull-left" id="logo-vitae" /></a>
			</footer>
		';
		$content = $this->helper->body($content);
		$content = $this->helper->html($this->helper->head( ).$content);
		$content .= '<script type="text/javascript">$(galactus_view_show("'.$page.'"));</script>'; 
		echo $content;
	}

}
?>
